package cn.ecut.Dao;

import java.sql.*;
public class adminsearch {

    public  String[] search(String scusname) throws SQLException, ClassNotFoundException {
        Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
        String connectionUrl = "jdbc:sqlserver://localhost:1433;" +
                "databaseName=thirdtest;user=mx;password=wanyuwen2000@;";/*注册驱动*/
        Connection coon = DriverManager.getConnection(connectionUrl);/*链接connection*/
         Statement state=coon.createStatement();
         String sql="select * from cutomer";
         ResultSet rs=state.executeQuery(sql);
         int flag=0;
         while (rs.next()){
             if (scusname.equals(rs.getString(1))){
             flag=1;
                 String[] s1 = new String[4];
                 for (int i=0;i<4;i++){
                     s1[0]=rs.getString(1);
                     s1[1]=rs.getString(2);
                     s1[2]=rs.getString(3);
                     s1[3]=rs.getString(4);
                     System.out.printf(rs.getString(i+1));

                 }
                 return s1;
             }
         }
    if(flag==0) System.out.print("数据库没有这个人，查询错误");
    return null;
    }


}
